﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nvigorate.Repository.Test;
using StructureMap;

namespace Nvigorate.Repository
{
    public abstract class BaseCommand<TRole, TDTO>
        where TRole : class
        where TDTO : class
    {
        private IRepository<TRole> _repository;
        protected IRepository<TRole> Repository { get { return _repository; } }

        protected IRepository<TModel> GetRepository<TModel>()
            where TModel : class
        {
            return ObjectFactory.GetInstance<IRepository<TModel>>();
        }

        public abstract ICommandResult Execute(TDTO dto);

        public BaseCommand(IRepository<TRole> repository)
        {
            _repository = repository;
        }
    }

    public interface ICommandResult
    {
        bool Failed { get; set; }
        IList<IDomainNotification> Notifications { get; set; }
    }

    public class SimpleResult : ICommandResult
    {
        public bool Failed { get; set; }
        public IList<IDomainNotification> Notifications { get; set; }
    }
}
